QUANTILE = 1

def loadCalificationsForContents(contents, user_id):
	for content in contents:
		content.calification = content.calification_set.filter(user_id=user_id)
		
		content.calification = None if len(content.calification) == 0 else content.calification[0].calification

def getContentPoints(likes, dislikes):
	total = likes + dislikes

	if total == 0:
		return 0;

	phat = likes / total;
	return ((phat + QUANTILE*QUANTILE/(2*total) - QUANTILE * sqrt((phat*(1-phat)+QUANTILE*QUANTILE/(4*total))/total))/(1+QUANTILE*QUANTILE/total))*MAX_POINTS;
